<template>
    <div class="wrapper">
        <v-head></v-head>
        <v-sidebar></v-sidebar>
        <div class="content-box" :class="{'content-collapse':collapse}">
            <div class="content">
                <el-breadcrumb separator="/"  style="padding:20px;" >
                    <!-- <el-breadcrumb-item :to="{path:'/'}">首页</el-breadcrumb-item> -->
                    <el-breadcrumb-item  v-for="(item,index) in this.$route.meta" :key="index" :to="item.url">
                        <router-link v-if="item.url" :to="item.url+`?id=${item.name=='田间管理'?'402881308c66bb59018c6720e9780027':''}`">{{item.name}}</router-link>
                        <a v-else>
                            {{item.name}}
                        </a>
                    </el-breadcrumb-item>
                </el-breadcrumb>
                <transition name="move" mode="out-in">
                    <keep-alive :include="tagsList">
                        <router-view></router-view>
                    </keep-alive>
                </transition>
                <el-backtop target=".content" :bottom="bottom"></el-backtop>
            </div>
        </div>
    </div>
</template>

<script>
import vHead from './Header.vue';
import vSidebar from './Sidebar.vue';
// import vTags from './Tags.vue';
import bus from './bus';
export default {
    data() {
        return {
            userInfo: localStorage.getItem('userType'),
            show1:true,
            show2:false,
            tagsList: [],
            collapse: false,
            crumbs:[],
            rob:[],
            bottom: 100,
            name:''
        };
    },
    components: {
        vHead,
        vSidebar,
        // vTags
    },
	methods:{
		// lcik(){

		// 	console.log(this.$route.meta)
		// }
	},
    created() {

        this.data = this.$store.getters.user
        if(this.data == null){
            this.$notify({
                title: '提示',
                message: '请重新登陆',
                type: 'info'
            });
            this.$router.push({
                path:"/login"
            })
        }
        bus.$on('collapse-content', msg => {
            this.collapse = msg;
        });


        // 只有在标签页列表里的页面才使用keep-alive，即关闭标签之后就不保存到内存中了。
        bus.$on('tags', msg => {
            let arr = [];
            for (let i = 0, len = msg.length; i < len; i++) {
                msg[i].name && arr.push(msg[i].name);
            }
            this.tagsList = arr;
        });
    },
    mounted(){
        var ide = localStorage.getItem("ide")
        if(ide == "qqq"){
            this.show1 = false
            this.show2 = true
        }else{
            this.show1 = true
            this.show2 = false
        }



        // console.log(this.$route.meta)
        // this.crumbs = this.$store.state.crumbs
        // var arr = []
        // for(var i=0;i<this.$store.state.crumbs.length;i++){
        //     var s = 0+i*2
        //     if(s<this.$store.state.crumbs.length){
        //         arr.push({path:this.$store.state.crumbs[0+i*2].path,title:this.$store.state.crumbs[1+i*2].title})
        //         this.rob = arr
        //     }else{
        //         return false
        //     }
        // }

        // console.log(this.crumbs)
    }
};
</script>

<style scoped>
    /* .wrapper{ */
        /* min-width:1200px; */
        /* overflow:auto; */
    /* } */
    .content{
        min-width:1100px;

    }
</style>
